/**
 * 抖音关注：程序员三丙
 * 知识星球：https://t.zsxq.com/j9b21
 */
package sanbing.example.dylike.util;

import org.springframework.util.StopWatch;


public class SanbingStopWatch extends StopWatch {

    public static SanbingStopWatch create(){
        SanbingStopWatch stopWatch = new SanbingStopWatch();
        stopWatch.start();
        return stopWatch;
    }

    public static SanbingStopWatch create(String taskName){
        SanbingStopWatch stopWatch = new SanbingStopWatch();
        stopWatch.start(taskName);
        return stopWatch;
    }

    public void startNew(String taskName){
        stop();
        start(taskName);
    }

    public long stopAndGetTotalTimeMillis(){
        stop();
        return getTotalTimeMillis();
    }

    public long stopAndGetTotalTimeNanos(){
        stop();
        return getLastTaskTimeNanos();
    }

    public long stopAndGetLastTaskTimeMillis(){
        stop();
        return getLastTaskTimeMillis();
    }

    public long stopAndGetLastTaskTimeNanos(){
        stop();
        return getLastTaskTimeNanos();
    }

}
